import express from 'express';
import { DormitoryController } from '../controllers/dormitoryController.js';
import { authenticateToken } from '../middleware/auth.js';

const router = express.Router();
const dormitoryController = new DormitoryController();

// 获取宿舍楼列表
router.get('/buildings', dormitoryController.getDormBuildings.bind(dormitoryController));

// 获取所有宿舍楼（用于下拉框）
router.get('/buildings/all', dormitoryController.getAllDormBuildings.bind(dormitoryController));

// 获取宿舍房间列表
router.get('/rooms', dormitoryController.getDormRooms.bind(dormitoryController));

// 创建宿舍楼
router.post('/buildings', dormitoryController.createDormBuilding.bind(dormitoryController));

// 更新宿舍楼
router.put('/buildings/:id', dormitoryController.updateDormBuilding.bind(dormitoryController));

// 删除宿舍楼
router.delete('/buildings/:id', dormitoryController.deleteDormBuilding.bind(dormitoryController));

// 创建宿舍房间
router.post('/rooms', dormitoryController.createDormRoom.bind(dormitoryController));

// 更新宿舍房间
router.put('/rooms/:id', dormitoryController.updateDormRoom.bind(dormitoryController));

// 删除宿舍房间
router.delete('/rooms/:id', dormitoryController.deleteDormRoom.bind(dormitoryController));

// 更新宿舍成员
router.put('/rooms/:id/members', dormitoryController.updateDormMembers.bind(dormitoryController));

export default router;